<?php
namespace data\service;
use data\model\RecordsModel;

class RecordsService extends BaseService {

    private $recordsModel = null;

    public function __construct() {
        parent::__construct();
        $this->recordsModel = new RecordsModel();
    }

    public function addRecords( $contentId , $uid , $type){
        $retVal = $this->recordsModel->save(['contentId'=>$contentId,'uid'=>$uid,'ctime'=>time(),'type' => $type ]);
        if( $retVal ){
            return $retVal;
        }
        return 0;
    }

    public function countCopys( $uid ){
        $countCopys = $this->recordsModel->getCount(['uid'=>$uid,'type'=>1],'id');
        return $countCopys;
    }

    public function countFavs( $uid ){
        $countFavs = $this->recordsModel->getCount(['uid'=>$uid,'type'=>2],'id');
        return $countFavs;
    }

}
